﻿$(document).ready(function () {

    var viewModel = {
        
        tasks: ko.observableArray([]),

        loadTasks: function () {

            OData.read(_serviceURL + "/ToDoListItems?$expand=Status,Category,User",
                function (data) {
                    viewModel.tasks.removeAll();
                    $.each(data.results, function (index, item) {
                        viewModel.tasks.push(ko.mapping.fromJS(item));
                    });
                });

        }
    };

    // Activates knockout.js
    ko.applyBindings(viewModel);

    viewModel.loadTasks();
	
});